const _ = require('lodash')
const moment = require('moment')
const notifier = require('node-notifier')

const timeTarget = '2019-07-01 09:58:00'

const notify = _.throttle(now => {
  notifier.notify({
    title: 'Notifier@' + now.format('HH:mm:ss'),
    message: '事件提醒',
  })
}, 20000)

console.log('将在' + timeTarget + '提醒')
setInterval(() => {
  const now = moment()
  if (now.isAfter(timeTarget)) notify(now)
}, 1000)
